﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>


<form action="spiel_anlegen_v.php" method="post">

<table>

<?php

	include("../inc/joomlaInt_admin.php");
	include("../inc/inc_configuration.php");

if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{
	
	$q="SELECT gid FROM $tbl_users WHERE id=$jUser";
					$qe=mysql_query($q);
					$qeo=mysql_fetch_object($qe);
					
					$gid=$qeo->gid;
					
					if ($gid!=$admingroup)
					{
						echo "Du bist kein Admin!";
						break;
					}
					
	$liga=$_GET["liga"];
	
	$lq = "SELECT * FROM $tbl_lt WHERE leagueId=$liga";
	$lqe = mysql_query($lq);
	$lqc = mysql_num_rows($lqe);

	$mAnz = ($lqc-1)*2;
	
	echo'<tr>
			<td>Spieltag:</td>
			<td><select name="matchday" Size="1">';
	
	$count = 1;
	while($count < $mAnz+1)
	{
		echo '<Option Value="',$count,'">',$count,'</option>';
		$count++;
	}
	echo"</select></td></tr>";
	
	
	
	$q = "SELECT * FROM $tbl_lg";
	$qe = mysql_query($q);
	
	echo '<tr>
			<td>Runde:</td>
			<td><select name="stage" Size="1">
				<Option Value="0">Keine</option>';
	
	while ($row = mysql_fetch_object($qe))
		{
			echo '<Option Value="',$row->id,'">' ,$row->groupName, '</option>';
		}
		
	echo"</select></td></tr>";
	
	
	
	$abfrage = "SELECT t.id, t.name FROM $tbl_teams t, $tbl_lt lt WHERE lt.leagueId=$liga AND lt.teamId=t.id ORDER BY name"; 
	$ergebnis = mysql_query($abfrage);
	
	echo '<tr>
			<td>Heim:</td>
			<td><select name="homeTeam" Size="1">';
	
	while ($row = mysql_fetch_object($ergebnis))
		{
			echo '<Option Value="',$row->id,'">' ,$row->name, '</option>';
		}
		
	echo"</select></td></tr>";
	

	$ergebnis = mysql_query($abfrage);
	
	echo '<tr>
			<td>Gast:</td>
			<td><select name="guestTeam" Size="1">';
	
	
	while ($row = mysql_fetch_object($ergebnis))
		{
			$t=$row->id;
			echo '<Option Value="',$t,'">' ,$row->name, '</option>';
		}
		
	echo "</select></td></tr>";
	
	echo " 		<tr>
					<td>Status:</td>
					<td>
						<select name='free'>
							<option value='0'>Nicht freigegeben</option>
							<option value='1'>Freigegeben</option>
							<option value='2'>Warten auf Bestätigung</option>
							<option value='3'>Bestätigt</option>
						</select>
					</td>
				</tr>
			</table>";
	
	echo '<input type="text" name="liga" value="',$liga,'" hidden>';


	;


echo '	<br>
		<input type="submit" value="Anlegen" class="button anlegen">
		</form>';

echo "<center><a href='ligaspiele.php?liga=",$liga,"' class='button zurueck'>Zurück</a></center>";
}
?>
</body>
</html>

